/**
 * @program: LeetCode
 * @description: LeetCode : 104. 二叉树的最大深度
 * @author: WXY
 * @create: 2023-01-02 15:37
 * @Version 1.0
 **/
public class num104_maxDepth {
    public static int maxDepth(TreeNode root) {
        return process(root).depth;
    }

    public static Info process(TreeNode node) {
        if (node == null) return new Info(0);
        Info leftInfo = process(node.left);
        Info rightInfo = process(node.right);
        int depth = Math.max(leftInfo.depth, rightInfo.depth) + 1;
        return new Info(depth);
    }

    public static class Info {
        int depth;

        public Info(int depth) {
            this.depth = depth;
        }
    }

    class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }


}
